// 云函数入口文件
const cloud = require('wx-server-sdk')
const creater = require('./create.js');
const path = require('path');

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

// 云函数入口函数
exports.main = async (event, context) => {

  console.log('main开始')
  
  var wordStream = creater.createWord();

  var filePath = "wordFiles";
  var fileName = Date.now() + '.docx';
  return await cloud.uploadFile({
    cloudPath: path.join(filePath, fileName),
    fileContent: wordStream
  });
}